uniform float pointRadius;
uniform vec3 halfVectorEye;
uniform vec2 invViewport;
uniform sampler2D shadowTex;
//uniform sampler3D noiseTex;
uniform sampler2D depthTex;

void main()
{
    // calculate eye-space sphere normal from texture coordinates
    vec3 N;
    N.xy = gl_TexCoord[0].xy*vec2(2.0, -2.0) + vec2(-1.0, 1.0);
    float r2 = dot(N.xy, N.xy);
    if (r2 > 1.0) discard;   // kill pixels outside circle
    N.z = sqrt(1.0-r2);

//    vec4 eyeSpacePos = vec4(gl_TexCoord[1].xyz + N*pointRadius, 1.0); // point on sphere

//    float alpha = exp(-r2*4.0);
    float alpha = saturate(1.0 - r2);
    alpha *= gl_Color.w;

    vec3 V = normalize(gl_TexCoord[1].xyz);
    float opacityCorrect = -V.z;
//    alpha /= opacityCorrect;

    gl_FragColor = vec4(gl_Color.xyz, alpha);
//    gl_FragColor = noise;
//    gl_FragColor = vec4(gl_Color.xyz * alpha, alpha); // premul alpha
}